<?php

namespace App\Http\Controllers\Car;

use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use App\Models\Atividade;
use Illuminate\Http\Request;

class AtividadeController extends Controller
{
    use ResponseData;
    public function list(Atividade $model,Request $request){
        $size = $request->input('size',10);
        $data = $model::query()->whereNull('deleted_at')->paginate($size);
        return $this->success($data);
    }
    public function store(Atividade $model,Request $request){
        $data = $request->all();
        $model->fill($data);
        $model->save();
        return $this->success('保存成功');
    }
    public function edit(Atividade $model,Request $request){
        $data = $model->find($request->id);
        return $this->success($data);
    }
    public function update(Atividade $model,Request $request){
        $data = $model->find($request->id);
        $data->update($request->all());
        return $this->success('修改成功');
    }
    public function destory(Atividade $model,Request $request){
        $data = $model->find($request->id);
        $data->deleted_at = now();
        $data->save();
        return $this->success('删除成功');
    }
}
